</%= javascript_include_tag "application" %>
<%= form_for(@cultural_heritage_culture,  :html => { :onsubmit => "return validate(this);"  }) do |f| %>
  <% if @cultural_heritage_culture.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@cultural_heritage_culture.errors.count, "error") %> prohibited this cultural_heritage_culture from being saved:</h2>

      <ul>
      <% @cultural_heritage_culture.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>
<div class="shadow">
<fieldset id="agrupacion">
  <legend>Datos Básicos </legend>
  <fieldset class="column-left">
  <div class="field">
    <label>Nombre:</label>
    <%= f.text_field :name %>
    <br></br>
  </div>
  <div class="field">
    <label id="cultural_heritage_culture_period_label">Periodo:</label>
      <%= f.select :period,@periods.collect { |t| [t.name,t.id]}, {:include_blank=>"Seleccione"}%>
    <br></br>
  </div>
  </fieldset>
  <fieldset class="column-right">
  <div class="field">
    <label>Descripción:</label>
    <%= f.text_area :description %>
  </div>
  </fieldset>
</fieldset>

<fieldset id="agrupacion">
  <legend>Ubicación </legend>
  <div class="field">
    <label>Locación:</label>
    <%= f.text_area :location %>
    <br></br>
  </div>
</fieldset>

 <fieldset id="agrupacion">
  <legend>Datos Adicionales </legend>
  <fieldset class="column-left">
  <div class="field">
    <label>Idioma:</label>
    <%= f.text_area :dlanguage %>
    <br></br>
  </div>
  <div class="field">
    <label>Religion:</label>
    <%= f.text_area :dreligion %>
  </div>
  </fieldset>
  <fieldset class="column-right">
  <div class="field">
    <label>Sociedad:</label>
    <%= f.text_area :dsocial %>
  </div>
  <div class="field">
    <label>Economia:</label>
    <%= f.text_area :economic %>
  </div>
  </fieldset>
</fieldset>
  <div class="actions">
    <%= f.submit "Enviar" %>

  </div>
</div>
<% end %>


<script type="text/javascript">
  // form validation function //
  function validate(form) {
    //input
    var name = form.cultural_heritage_culture_name.value;
    //select
    var period = form.cultural_heritage_culture_period.value;
    //input number
    

    /*NO TOCAR*
    /*FIN DE NO TOCAR*/

    if(name == "") {
      inlineMsg('cultural_heritage_culture_name','Debe ingresar un nombre para la Cultura.',3);
      return false;
    }
    if(!name.match(nameRegex)) {
      inlineMsg('cultural_heritage_culture_name','Debe de ingresar un nombre válido.',3);
      return false;
    }
    /*Para un select*/
    if(period == "") {
      inlineMsg('cultural_heritage_culture_period','Debe seleccionar un periodo para la Cultura.',3);
      return false;
    }
    return true;
  }
</script>